#ifndef __STEPPER_MOTOR_H
#define __STEPPER_MOTOR_H
#include "ti_msp_dl_config.h"
#define STEP_A_INST PWM_A_INST
#define STEP_B_INST PWM_B_INST
#define STEP_DIVISION 16 //细分
#define STEP_ANGLE 1.8f //每步角度
#define STEP_ANGLE_DIVIDED (STEP_ANGLE / STEP_DIVISION) //每细分角度
#define STEPPER_FRONT 1
#define STEPPER_BACK 0
#define STEPPER_STOP 2
#define STEEPER_MOTOR_A_CNT_MAX 3200
#define STEEPER_MOTOR_A_CNT_MIN -3200
#define STEEPER_MOTOR_B_CNT_MIN -800
#define STEEPER_MOTOR_B_CNT_MAX 800
#define SPEED_LIMIT 5.0f //速度限幅
typedef struct
{
    uint8_t ID;
    uint8_t Enable; // 使能信号
    uint8_t direction; // 0: 正转, 1: 反转  
    float stepper_angle; // 步进电机角度 单位: 度
    float stepper_speed; // 步进电机速度 单位: 度/秒
    
} StepperMotor;
extern StepperMotor stepper_motor_A;
extern StepperMotor stepper_motor_B;
extern int StepperCnt_buff[2]; //电机A 和 电机B
void StepperMotor_SetPWMFreq(StepperMotor *motor, float freq); // 设置PWM频率
void StepperMotor_SetSpeed(StepperMotor *motor, float speed,uint8_t un_limit); // 设置速度
void StepperMotor_init(StepperMotor *motor); // 初始化步进电机


#include "ti_msp_dl_config.h"
#include "PID.h"
#endif



